﻿using ConfExpert.Datasets;
using ConfExpert.Forms.Base;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Repository;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Layout;
using DevExpress.XtraLayout;
using DevTeam;

using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Windows.Forms;

namespace ConfExpert.Entities
{ 
    public partial class Renkler : XForm
    {
        bool Add2db = false;
        BindingSource bs, bsB, bsBL;
        LayoutViewField lvfPhoto;
        Color color1 = Color.Red;
        Color color2 = Color.Transparent;
        List<int> selection = new List<int>();

        public Renkler()
        {
            InitializeComponent();
            TAM.BurcuTableAdapter = new Datasets.MyDataTableAdapters.BurcuTableAdapter();
            TAM.BurcuLinesTableAdapter = new Datasets.MyDataTableAdapters.BurcuLinesTableAdapter();
        }

        private void Renkler_Load(object sender, EventArgs e)
        {
            Add2db  =ytk(112); //Kaydet butonu
            btnBurcu.Visibility = ytk(112) ? DevExpress.XtraBars.BarItemVisibility.Always : DevExpress.XtraBars.BarItemVisibility.Never;
            bs = new BindingSource(ds, "xKartela");
            bsB = new BindingSource(ds, "Burcu");
            bsBL = new BindingSource(bsB, "FK_BurcuLines_Burcu_BurcuId");   //ds, "BurcuLines");//
            AddBsToList(bsB, bsBL);

            InitGridView(gvArticle, bsB);
            gvArticle.Columns["BurcuId"].Visible = gvArticle.Columns["Photo"].Visible = false;

            gle.Properties.Assign(RI(Rp.V_Kumas));
            gle.EditValueChanged += new EventHandler(gle_EditValueChanged);

            pictureEdit1.DataBindings.Add("EditValue", bsB, "Photo");
            pictureEdit1.Click += new EventHandler(pictureEdit1_Click);
            /*
            #region Eski
            //LayoutViewField.SizeConstraintsType property to Custom and evaluate the LayoutViewField.MinSize.Height;
            //lvRenkler.OptionsMultiRecordMode.MaxCardRows = 30;
            //lvRenkler.TemplateCard.Height = 500;
            //lvRenkler.ZoomView();
            //lvRenkler.OptionsMultiRecordMode.StretchCardToViewWidth = true;
            //lvRenkler.OptionsMultiRecordMode.StretchCardToViewHeight = true;
            //this.lvRenkler.TemplateCard.BackgroundImageLayout = ImageLayout.Tile;
            //this.lvRenkler.OptionsView.CardArrangeRule = DevExpress.XtraGrid.Views.Layout.LayoutCardArrangeRule.AllowPartialCards;

            //lvRenkler.OptionsView.ShowCardCaption = false;
            //lvRenkler.OptionsView.ShowCardExpandButton = false;
            //RepositoryItemCheckEdit repositoryItemCheckEdit1 = new RepositoryItemCheckEdit();
            //lvRenkler.Columns["SEÇ"].ColumnEdit = repositoryItemCheckEdit1;
            //repositoryItemCheckEdit1.CheckedChanged+=new EventHandler(repositoryItemCheckEdit1_CheckedChanged);
            //lvRenkler.CardMinSize = new Size(gcRenkler.ClientRectangle.Width / 5, gcRenkler.ClientRectangle.Height / 5);

            #endregion



            InitLV();
            */
            cbGosterGizle.CheckedChanged += new EventHandler(cbGosterGizle_CheckedChanged);
            btnBurcu.ItemClick += BtnBurcu_ItemClick;

            cbChangeMode.CheckedChanged += CbChangeMode_CheckedChanged;
            cbChangeMode.Checked = true;

            gvArticle.AddSummary();

            //rangeTrackBarControl1.Value = new DevExpress.XtraEditors.Repository.TrackBarRange(3, 8);
            ((RepositoryItemTrackBar)trackBarControl1.Edit).Minimum = 1;
            ((RepositoryItemTrackBar)trackBarControl1.Edit).Maximum = 10;
            trackBarControl1.EditValue = 2;
        }

        //void lvRenkler_DoubleClick(object sender, EventArgs e)
        //{
        //    Goster(intParse(lvRenkler.DataSource as BindingSource, "ProductId"));
        //}

        void pictureEdit1_Click(object sender, EventArgs e)
        {
            Goster(intParse(bsB, "ProductId"));
        }

        void InitLV()
        {
            //lvRenkler.TemplateCard.MaxSize = new Size(x, ilkAyrim);
            lvRenkler.Click -= new EventHandler(lvRenkler_Click);
            lvRenkler.CustomDrawCardFieldValue -= new global::DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventHandler(lvRenkler_CustomDrawCardFieldValue);
            lvRenkler.Columns.Clear();

            if (cbChangeMode.Checked)
            {
                lvRenkler.GridControl.DataSource = bsBL;
                lvRenkler.PopulateColumns();
                lvRenkler.Columns["BurcuId"].Visible = lvRenkler.Columns["BurcuLinesId"].Visible = false;
                lvRenkler.OptionsBehavior.Editable = true;

            }
            else
            {
                lvRenkler.GridControl.DataSource = bs;
                lvRenkler.PopulateColumns();
                lvRenkler.Columns["Dist"].Visible = false;
                lvRenkler.CustomDrawCardFieldValue += new global::DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventHandler(lvRenkler_CustomDrawCardFieldValue);
                lvRenkler.OptionsBehavior.Editable = false;

            }

            lvRenkler.Click += new EventHandler(lvRenkler_Click);
            lvRenkler.Columns["Photo"].ColumnEdit = new RepositoryItemPictureEdit();
            lvfPhoto = lvRenkler.Columns["Photo"].LayoutViewField;
            lvfPhoto.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
            lvfPhoto.MinSize = lvfPhoto.MaxSize = new Size(72, 72);  //140x140 idi

            lvRenkler.CardMinSize = new Size(72, 72);
            lvRenkler.OptionsMultiRecordMode.MultiRowScrollBarOrientation = DevExpress.XtraGrid.Views.Layout.ScrollBarOrientation.Vertical;
            lvRenkler.OptionsView.ViewMode = DevExpress.XtraGrid.Views.Layout.LayoutViewMode.MultiRow;
            lvRenkler.OptionsBehavior.UseTabKey = true;
            lvRenkler.OptionsBehavior.KeepFocusedRowOnUpdate = true;

            //lvRenkler.OptionsItemText.TextToControlDistance = 10;
            //lvRenkler.OptionsMultiRecordMode.StretchCardToViewWidth = true;
            //lvRenkler.OptionsSelection.MultiSelect = true;
            //lvRenkler.OptionsView.ContentAlignment = System.Drawing.ContentAlignment.TopCenter;
            //lvRenkler.OptionsView.ShowCardBorderIfCaptionHidden = false;
            lvRenkler.OptionsView.ShowCardCaption = false;
            lvRenkler.OptionsView.ShowCardExpandButton = false;
            //lvRenkler.OptionsView.ShowCardLines = false;
            //lvRenkler.OptionsView.ShowFieldHints = false;
            //lvRenkler.OptionsView.ShowHeaderPanel = false;

            lvRenkler.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Default;

            foreach (LayoutViewField lvf in lvRenkler.TemplateCard.Items)
            {
                lvf.Padding = new DevExpress.XtraLayout.Utils.Padding(4, 4, 0, 0);
                lvf.EditorPreferredWidth = 72;
            }
            layoutViewCard1.Padding = new DevExpress.XtraLayout.Utils.Padding(2, 2, 0, 0);

            foreach (object ci in lvRenkler.Items)
                if (ci is LayoutControlItem)
                    ((LayoutControlItem)ci).TextVisible = false;

            foreach (LayoutViewColumn lvc in lvRenkler.Columns)
            {
                lvc.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False;
                lvc.OptionsFilter.AllowFilter = false;
            }
        }

        private void CbChangeMode_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            ds.Burcu.Clear();
            ds.BurcuLines.Clear();
            ds.xKartela.Clear();

            gle.Visible = cbGosterGizle.Visible = !cbChangeMode.Checked;
            trackBarControl1.Visibility = !cbChangeMode.Checked ? DevExpress.XtraBars.BarItemVisibility.Always : DevExpress.XtraBars.BarItemVisibility.Never;
            GetDetails("Burcu;BurcuLines", "GetRenkler", -1, cbChangeMode.Checked ? 1 : 0, Add2db);
            gvArticle.BestFitColumns();

            InitLV();

        }



        void lvRenkler_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e)
        {
            if (e.IsGetData && ds.xKartela.Rows.Count > 0)
            {
                LayoutView view = (LayoutView)sender;
                int rh = view.GetRowHandle(e.ListSourceRowIndex);
                e.Value = ds.xKartela.Select("ProductId=" + intParse(view.GetRowCellValue(rh, "ProductId")).ToString())[0]["Photo"];
            }
            //e.Value = Image.FromFile(path + CarId + ".jpg");
        }


        void lvRenkler_CustomDrawCardFieldValue(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            //if (lvRenkler.IsRowSelected(e.RowHandle))
            if (lvRenkler.GetRowCellValue(e.RowHandle, "Dist") != DBNull.Value)
                e.Appearance.BackColor = Color.Gold;
            //else
            //    e.Appearance.BackColor = Color.GreenYellow;
        }

        void cbGosterGizle_CheckedChanged(object sender, EventArgs e)
        {
            bs.EndEdit();
            bs.Filter = cbGosterGizle.Checked ? "Dist is not null" : string.Empty;
        }

        void lvRenkler_Click(object sender, EventArgs e)
        {
            if (Control.ModifierKeys == Keys.Control)
                Goster(intParse(lvRenkler.DataSource as BindingSource, "ProductId"));

            else if (Control.ModifierKeys == Keys.Shift)
            {
                if (XtraMessageBox.Show("Mevcut gruplamayı kaydedip bu artikelle yeni bir grup başlatmak istiyor musunuz?", "Yeni grup", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                {
                    if (Add2db)
                        btnBurcu.PerformClick();
                    int PId = intParse(lvRenkler.DataSource as BindingSource, "ProductId");
                    cbChangeMode.Checked = false;
                    gle.EditValue = PId;
                }
            }

            else if (!cbChangeMode.Checked)
            {
                if (lvRenkler.GetFocusedRowCellValue("Dist") == DBNull.Value)
                    lvRenkler.SetFocusedRowCellValue("Dist", 0);
                else
                    lvRenkler.SetFocusedRowCellValue("Dist", DBNull.Value);

                //this.Invalidate();
            }
        }

        private void BtnBurcu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (!cbChangeMode.Checked)
            {
                //ds.BurcuLines.Clear();

                foreach (DataRow r in ds.xKartela.Select("Dist is not null"))
                {
                    MyData.BurcuLinesRow bl = ds.BurcuLines.NewBurcuLinesRow();
                    bl.BurcuId = intParse(bsB, "BurcuId");
                    bl.ProductId = intParse(r["ProductId"]);
                    ds.BurcuLines.AddBurcuLinesRow(bl);

                    r["Dist"] = DBNull.Value;
                }
            }

            Save();
        }

        //MyData.BurcuRow br;
        void gle_EditValueChanged(object sender, EventArgs e)
        {
            ds.xKartela.Clear();
            ds.BurcuLines.Clear();
            cbGosterGizle.Checked = false;

            GetDetails("xKartela;Burcu", "GetRenkler", intParse(gle.EditValue), trackBarControl1.EditValue.ToInt() * 2, Add2db);
            gvArticle.FocusedRowHandle = gvArticle.LocateByValue("ProductId", intParse(gle.EditValue));
            //gvB.MoveLast();

            

            //MyData.BurcuRow b = ds.Burcu.NewBurcuRow();
            //b.Notes = "test";
            //ds.Burcu.AddBurcuRow(b);

            gvArticle.MakeRowVisible(gvArticle.FocusedRowHandle);
        }
        
        /*
         * 
         * 
 
            LayoutViewColumn colPhoto = lvRenkler.Columns.AddField("Photo");
            colPhoto.Caption = "Photo";
            colPhoto.ColumnEdit = new RepositoryItemPictureEdit();
            colPhoto.FieldName = "Photo";
            colPhoto.LayoutViewField = new LayoutViewField(); // this.layoutViewField_layoutViewColumn1;
            
            lvfPhoto = colPhoto.LayoutViewField;
            lvfPhoto.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
            lvfPhoto.MinSize = new Size(120, 120);  //140x140 idi
            lvfPhoto.Move(lvRenkler.Columns["ProductId"].LayoutViewField, DevExpress.XtraLayout.Utils.InsertType.Top);

            foreach (DevExpress.XtraGrid.Columns.GridColumn col in lvRenkler.Columns)
                if (col.FieldName != this.Name + "Id")
                    MapColumn(col);
            
            //lvRenkler.Columns["QtyAvailable"].LayoutViewField.Move(lvRenkler.Columns["QtyReserved"].LayoutViewField, DevExpress.XtraLayout.Utils.InsertType.Right);
            //lvRenkler.Columns["Tags"].LayoutViewField.Move(lvRenkler.Columns["EnGrubuId"].LayoutViewField, DevExpress.XtraLayout.Utils.InsertType.Right);

            //btnTalepOlustur.Click += new EventHandler(btnListele_Click);
            //lvRenkler.Click += new EventHandler(lvRenkler_Click);
            //lvRenkler.CustomDrawCardFieldValue += new RowCellCustomDrawEventHandler(lvRenkler_CustomDrawCardFieldValue);
            //lvRenkler.CustomFieldValueStyle += new DevExpress.XtraGrid.Views.Layout.Events.LayoutViewFieldValueStyleEventHandler(this.OnCustomFieldValueStyle);
            //lvRenkler.CustomFieldEditingValueStyle += new DevExpress.XtraGrid.Views.Layout.Events.LayoutViewFieldEditingValueStyleEventHandler(this.OnCustomFieldEditingValueStyle);

            //gleProductCategory.EditValueChanged += new System.EventHandler(UpdateFilter);
            //chkSecilen.CheckedChanged += new System.EventHandler(UpdateFilter);
            //gleKalite.EditValueChanged += new EventHandler(UpdateFilter);
            //teDesen.EditValueChanged += new System.EventHandler(UpdateFilter);
            //teRenk.EditValueChanged += new System.EventHandler(UpdateFilter);
            //teKomp.EditValueChanged += new EventHandler(UpdateFilter);
            //teKons.EditValueChanged += new EventHandler(UpdateFilter);
            //teTags.EditValueChanged += new EventHandler(UpdateFilter);

            //gleKalite.Properties.Assign(RI(Rp.Kalite));
            //GleExtend(gleCustomer);
            //gleCustomer.Properties.Assign(RI(Rp.V_Customer));
            //gleCustomer.EditValueChanged += new EventHandler(gleCustomer_EditValueChanged);
            //gleCustomer.EditValue = 1;


            //beSaved.Properties.ReadOnly = true;
            //btnKaydet.Click += new EventHandler(btnKaydet_Click);
            //btnFarkliKaydet.Click += new EventHandler(btnFarkliKaydet_Click);
            //beSaved.ButtonClick += new ButtonPressedEventHandler(beSaved_ButtonClick);

            //lvRenkler.OptionsView.ShowCardCaption = true;

            //Use skin color for regular controls!
            //DevExpress.Skins.Skin currentSkin = DevExpress.Skins.CommonSkins.GetSkin(appLookAndFeel.LookAndFeel);
            //Color c = currentSkin.TranslateColor(SystemColors.Control);
            //labelControl1.ForeColor = c;

            //colorEdit1.EditValue = color1;
            //colorEdit1.EditValueChanged += new EventHandler(colorEdit1_EditValueChanged);

            //colorEdit2.EditValue = color2;
            //colorEdit2.EditValueChanged += new EventHandler(colorEdit2_EditValueChanged);

            //zoomTrackBarControl1.EditValueChanged += new EventHandler(trackBarControl1_EditValueChanged);
            //zoomTrackBarControl1.EditValue = 0;

            //cmbSiralama.EditValueChanged += new EventHandler(cmbSiralama_EditValueChanged);
            //cmbSiralama.EditValue = "ProductId";

            //lvRenkler.CustomUnboundColumnData += new CustomColumnDataEventHandler(lvRenkler_CustomUnboundColumnData);
            //cmbDetail.EditValueChanged += new EventHandler(cmbDetail_EditValueChanged);
            //cmbDetail.EditValue = "Mini";


            //backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(backgroundWorker1_DoWork);
            //backgroundWorker1.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(backgroundWorker1_RunWorkerCompleted);
            //backgroundWorker1.RunWorkerAsync();

                     * 
        void lvRenkler_Click(object sender, EventArgs e)
        {
            if (e is MouseEventArgs)
            {
                LayoutView lv = (LayoutView)sender;
                int ProductId = (int)lvRenkler.GetFocusedRowCellValue("ProductId");

                if (((MouseEventArgs)e).Button == MouseButtons.Right)
                    Goster(ProductId);
                else
                {
                    if (lv.FocusedColumn != null)
                    {
                        if (lv.FocusedColumn.FieldName.Contains("Photo"))
                        {
                            if (selection.Contains(ProductId))
                            {
                                selection.Remove(ProductId);
                                ds.xRenklerK.FindByProductId(ProductId)["SEÇ"] = false;
                            }
                            else
                            {
                                selection.Add(ProductId);
                                ds.xRenklerK.FindByProductId(ProductId)["SEÇ"] = true;
                            }

                            lv.InvalidateCard(lv.FocusedRowHandle);
                        }
                        //else
                        //    new RezerveAyrimDetayi(ProductId, intParse(gleCustomer.EditValue)).ShowDialog();
                        //            GetDetails("xDepoRez;xDepoAll", "GetDepoArtikel", ProductId, CustomerId);

                    }
                }
            }
        }
        
        void cmbDetail_EditValueChanged(object sender, EventArgs e)
        {
            lvRenkler.Refresh();
        }

        void lvRenkler_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e)
        {
            if (e.IsGetData && ds.xPhotos.Rows.Count > 0)
            {
                LayoutView view = (LayoutView)sender;
                switch (cmbDetail.SelectedIndex)
                {
                    case 0:
                        if (!ds.xPhotos.FindByProductId(intParse(view.GetListSourceRowCellValue(e.ListSourceRowIndex, "ProductId"))).IsPhotoNull())
                            e.Value = ds.xPhotos.FindByProductId(intParse(view.GetRowCellValue(e.ListSourceRowIndex, "ProductId"))).Photo;
                        break;
                    case 1:
                        if (!ds.xPhotos.FindByProductId(intParse(view.GetListSourceRowCellValue(e.ListSourceRowIndex, "ProductId"))).IsPhotoNull())
                            e.Value = ds.xPhotos.FindByProductId(intParse(view.GetListSourceRowCellValue(e.ListSourceRowIndex, "ProductId"))).Photo;
                        break;
                    case 2:
                        if (!ds.xPhotos.FindByProductId(intParse(view.GetListSourceRowCellValue(e.ListSourceRowIndex, "ProductId"))).IsPhotoLargeNull())
                            e.Value = ds.xPhotos.FindByProductId(intParse(view.GetListSourceRowCellValue(e.ListSourceRowIndex, "ProductId"))).PhotoLarge;
                        break;
                }

                //e.Value = Image.FromFile(path + CarId + ".jpg");
            }
        }

        void cmbSiralama_EditValueChanged(object sender, EventArgs e)
        {
            bs.Sort = cmbSiralama.EditValue.ToString();
        }
        
        void colorEdit1_EditValueChanged(object sender, EventArgs e)
        {
            if (colorEdit1.EditValue == null)
                colorEdit1.EditValue = Color.White;

            color1 = (Color)colorEdit1.EditValue;
            lvRenkler.Refresh();
        }

        void colorEdit2_EditValueChanged(object sender, EventArgs e)
        {
            if (colorEdit2.EditValue == null)
                colorEdit2.EditValue = Color.White;

            color2 = (Color)colorEdit2.EditValue;
            lvRenkler.Refresh();
        }

        void beSaved_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            SavedKartela sk = new SavedKartela();
            if (sk.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                if (intParse(sk.SavedKartelaId) > 0)
                {
                    beSaved.EditValue = sk.SavedKartelaId;
                    ds.SavedKartela.Clear();
                    GetDetails("SavedKartela", "GetSavedKartela", intParse(beSaved.EditValue));
                    teAciklama.Text = ds.SavedKartela.Rows[0]["Notes"].ToString();

                    selection.Clear();
                    foreach (DataRow dr in ds.xRenklerK.Select("SEÇ = 1"))
                        dr["SEÇ"] = false;

                    foreach (string Message in ds.SavedKartela.Rows[0]["List"].ToString().Split(new char[] { ' ' }))
                        if (Message != string.Empty)
                        {
                            int ProductId = intParse(Message);
                            ds.xRenklerK.FindByProductId(ProductId).SEÇ = true;
                            selection.Add(ProductId);
                        }
                }
        }
       
        void btnFarkliKaydet_Click(object sender, EventArgs e)
        {
            GetDetails("SavedKartela", "UpdSavedKartela", 0, teAciklama.Text, WhoAmI.ToString(), GetSelection());
            bsSavedKartela.MoveLast();
            beSaved.EditValue = ((DataRowView)bsSavedKartela.Current).Row["SavedKartelaId"];
        }

        void btnKaydet_Click(object sender, EventArgs e)
        {
            //lvRenkler.SaveLayoutToXml("D:\\layout2.xml");
            //ExecQuery("UpdSavedKartela", intParse(gl.EditValue), teAciklama.Text, WhoAmI.ToString(), GetSelection());
        }
        
        void trackBarControl1_EditValueChanged(object sender, EventArgs e)
        {
            int imgWidth = 75 + 20 * zoomTrackBarControl1.Value;
            lvfPhoto.MinSize = new Size(imgWidth, imgWidth);

            //if (imgWidth >= (cmbDetail.SelectedIndex == 0 ? 100 : cmbDetail.SelectedIndex == 1 ? 180 : 320))
                ((RepositoryItemPictureEdit)lvRenkler.Columns["Photo"].ColumnEdit).SizeMode = PictureSizeMode.Zoom;
            //else
            //    ((RepositoryItemPictureEdit)lvRenkler.Columns["Photo"].ColumnEdit).SizeMode = PictureSizeMode.Clip;



            //if (imgWidth >= 160)
            //    lvfPhoto.DataBindings.Add(new Binding("EditValue", bsPhotos, "Photo"));
            //else if (imgWidth >= 80)
            //    lvfPhoto.DataBindings.Add(new Binding("EditValue", bsPhotos, "Photo2"));
            //else
            //    lvfPhoto.DataBindings.Add(new Binding("EditValue", bsPhotos, "Photo3"));
        }
        
        void gleCustomer_EditValueChanged(object sender, EventArgs e)
        {
            RefreshData();
        }

        private void RefreshData()
        {
            ds.xKartela.Clear();
            GetDetails("xKartela", "GetRenkler", st, intParse(gleCustomer.EditValue));
        }
        
        //private void GetPhotosMain()
        //{
        //    Invoke(new GetCallback(GetPhotos));
        //}

        //delegate void GetCallback();

        string GetSelection()
        {
            bs.EndEdit();
            string lst = string.Empty;
            foreach(int i in selection)
                lst+= i.ToString() + " ";
            return lst.Trim();
        }

        string GetSelection2()
        {
            bs.EndEdit();
            string lst = string.Empty, lst2 = string.Empty;
            foreach (int i in selection)
                lst += i.ToString() + ';';

            //ConfExpert.Datasets.MyData.xRenklerKRow dr = ds.xRenklerK.FindByProductId(i);
            //lst += dr.Name + Environment.NewLine;
            
            //if (lst != string.Empty)
            //    Clipboard.SetText(lst);
            return lst.Trim();
        }

        void btnListele_Click(object sender, EventArgs e)
        {

            YeniTalep talep = new YeniTalep(GetSelection2());
            talep.ShowDialog();

            //if (talep.ShowDialog() == DialogResult.OK)
            //    GetDetails("Talep;TalepLines", "GetTalep");




            //XtraMessageBox.Show(GetSelection2(), "Seçtiğiniz artikeller", MessageBoxButtons.OK);
        }
        
        private void lvRenkler_CustomDrawCardFieldValue(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            LayoutView view = sender as LayoutView;
            if (e.Column.FieldName.Contains("Photo"))
            {
                if (selection.Contains((int)(view.GetRowCellValue(e.RowHandle, "ProductId"))))
                {
                    Rectangle rect = new Rectangle(e.Bounds.X - 1, e.Bounds.Y - 1, e.Bounds.Width + 1, e.Bounds.Height + 1);
                    e.Graphics.DrawRectangle(new Pen(color1, 3), rect);
                }
                else
                {
                    Rectangle rect = new Rectangle(e.Bounds.X, e.Bounds.Y - 1, e.Bounds.Width, e.Bounds.Height);
                    e.Graphics.DrawRectangle(new Pen(color2, 1), rect);
                }
            }

        }
       
        //In skinning paint schemes, the background of card captions is painted using a corresponding skin element, so changing the background colors via the CardCaption and FocusedCardCaption properties is not in effect. 

        private void UpdateFilter(object sender, EventArgs e)
        {
            List<string> flt = new List<string>();
            if (teDesen.EditValue != null)
                if (teDesen.EditValue.ToString() != string.Empty)
                    flt.Add((st == StokTipi.Kumas ? "DesenNo" : "StokKodu") + " like '%" + teDesen.EditValue.ToString() + "%'");
            if (teRenk.EditValue != null)
                if (teRenk.EditValue.ToString() != string.Empty)
                    flt.Add("Renk like '%" + teRenk.EditValue.ToString() + "%'");
            if (teKomp.EditValue != null)
                if (teKomp.EditValue.ToString() != string.Empty)
                    flt.Add("Kompozisyon like '%" + teKomp.EditValue.ToString() + "%'");
            if (teKons.EditValue != null)
                if (teKons.EditValue.ToString() != string.Empty)
                    flt.Add("Konstruksiyon like '%" + teKons.EditValue.ToString() + "%'");
            if (teTags.EditValue != null)
                if (teTags.EditValue.ToString() != string.Empty)
                {
                    List<string> tags = new List<string>();
                    foreach (string Message in teTags.Text.Split(new char[] { ',', ';' }))
                        tags.Add("Tags like '%" + Message.Trim() + "%'");
                    flt.Add("(" + String.Join(" OR ", tags.ToArray()) + ")");
                }
            if (gleKalite.EditValue != null)
                flt.Add("KaliteId = " + gleKalite.EditValue.ToString());
            if (chkSecilen.Checked)
                flt.Add("SEÇ = 1");
            if (st == StokTipi.Aksesuar)
                if (gleProductCategory.EditValue != null)
                    flt.Add("ProductCategoryId = " + gleProductCategory.EditValue.ToString());

            bs.Filter = String.Join(" AND ", flt.ToArray());
            
        }
         */
    }
}
